package thesis.filesharing.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Text;

@Entity
public class Exercise {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Key exerciseKey;
	
	@Basic
	private String exerciseTitle;
	
	@Basic
	private Text exerciseContent;
	
	@Basic
	@Temporal(TemporalType.DATE)
	private Date demandDate;
	
	@Basic
	@Temporal(TemporalType.DATE)
	private Date deadline;
	
	@Basic
	private Boolean groupExercise;
	
	@Basic
	private String exerciseType;
	
	@ManyToOne(fetch = FetchType.LAZY)
	private Clazz clazz;
	
	@Basic
	private Set<Key> exerciseCategoryKeys = new HashSet<Key>();
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "exercise")
	private Set<ExerciseFile> exerciseFiles = new HashSet<ExerciseFile>();
	
	public Exercise() {
		
	}
	
	public Exercise(String exerciseTitle, Text exerciseContent,
			Date demandDate, Date deadline, Boolean groupExercise,
			String exerciseType, Clazz clazz) {
		this.exerciseTitle = exerciseTitle;
		this.exerciseContent = exerciseContent;
		this.demandDate = demandDate;
		this.deadline = deadline;
		this.groupExercise = groupExercise;
		this.exerciseType = exerciseType;
		this.clazz = clazz;
	}

	public Exercise(String exerciseTitle, Text exerciseContent,
			Date demandDate, Date deadline, Boolean groupExercise,
			String exerciseType, Clazz clazz, Set<Key> exerciseCategoryKeys) {
		this.exerciseTitle = exerciseTitle;
		this.exerciseContent = exerciseContent;
		this.demandDate = demandDate;
		this.deadline = deadline;
		this.groupExercise = groupExercise;
		this.exerciseType = exerciseType;
		this.clazz = clazz;
		this.exerciseCategoryKeys = exerciseCategoryKeys;
	}

	public Exercise(Key exerciseKey, String exerciseTitle,
			Text exerciseContent, Date demandDate, Date deadline,
			Boolean groupExercise, String exerciseType, Clazz clazz) {
		this.exerciseKey = exerciseKey;
		this.exerciseTitle = exerciseTitle;
		this.exerciseContent = exerciseContent;
		this.demandDate = demandDate;
		this.deadline = deadline;
		this.groupExercise = groupExercise;
		this.exerciseType = exerciseType;
		this.clazz = clazz;
	}

	public Exercise(Key exerciseKey, String exerciseTitle,
			Text exerciseContent, Date demandDate, Date deadline,
			Boolean groupExercise, String exerciseType, Clazz clazz,
			Set<Key> exerciseCategoryKeys) {
		this.exerciseKey = exerciseKey;
		this.exerciseTitle = exerciseTitle;
		this.exerciseContent = exerciseContent;
		this.demandDate = demandDate;
		this.deadline = deadline;
		this.groupExercise = groupExercise;
		this.exerciseType = exerciseType;
		this.clazz = clazz;
		this.exerciseCategoryKeys = exerciseCategoryKeys;
	}
	
	public Exercise(String exerciseTitle, Text exerciseContent,
			Date demandDate, Date deadline, Boolean groupExercise,
			String exerciseType, Clazz clazz, Set<Key> exerciseCategoryKeys,
			Set<ExerciseFile> exerciseFiles) {
		this.exerciseTitle = exerciseTitle;
		this.exerciseContent = exerciseContent;
		this.demandDate = demandDate;
		this.deadline = deadline;
		this.groupExercise = groupExercise;
		this.exerciseType = exerciseType;
		this.clazz = clazz;
		this.exerciseCategoryKeys = exerciseCategoryKeys;
		this.exerciseFiles = exerciseFiles;
	}

	public Key getExerciseKey() {
		return exerciseKey;
	}

	public void setExerciseKey(Key exerciseKey) {
		this.exerciseKey = exerciseKey;
	}

	public String getExerciseTitle() {
		return exerciseTitle;
	}

	public void setExerciseTitle(String exerciseTitle) {
		this.exerciseTitle = exerciseTitle;
	}

	public Text getExerciseContent() {
		return exerciseContent;
	}

	public void setExerciseContent(Text exerciseContent) {
		this.exerciseContent = exerciseContent;
	}

	public Date getDemandDate() {
		return demandDate;
	}

	public void setDemandDate(Date demandDate) {
		this.demandDate = demandDate;
	}

	public Date getDeadline() {
		return deadline;
	}

	public void setDeadline(Date deadline) {
		this.deadline = deadline;
	}

	public Boolean getGroupExercise() {
		return groupExercise;
	}

	public void setGroupExercise(Boolean groupExercise) {
		this.groupExercise = groupExercise;
	}

	public String getExerciseType() {
		return exerciseType;
	}

	public void setExerciseType(String exerciseType) {
		this.exerciseType = exerciseType;
	}

	public Clazz getClazz() {
		return clazz;
	}

	public void setClazz(Clazz clazz) {
		this.clazz = clazz;
	}

	public Set<Key> getExerciseCategoryKeys() {
		return exerciseCategoryKeys;
	}

	public void setExerciseCategoryKeys(Set<Key> exerciseCategoryKeys) {
		this.exerciseCategoryKeys = exerciseCategoryKeys;
	}

	public Set<ExerciseFile> getExerciseFiles() {
		return exerciseFiles;
	}

	public void setExerciseFiles(Set<ExerciseFile> exerciseFiles) {
		this.exerciseFiles = exerciseFiles;
	}
}
